package org.black.phoneUtility.sms.reply.util;

import org.black.phoneUtility.sms.reply.database.dataModel.SmsReply;
import org.black.phoneUtility.sms.reply.provider.SmsReplyContract;

import android.database.Cursor;

public class DateTimeUtil {
	private DateTimeUtil() {

	}

	public static long extractHoursFromDateTimeInMilliSeconds(long milliSeconds) {
		return (milliSeconds / 3600000l);
	}

	public static long extractMinutesFromDateTimeInMilliSeconds(
			long milliSeconds) {
		return (milliSeconds % 3600000l) / 60000;
	}

	public static boolean isNeverRepeat(SmsReply smsReply) {
		boolean result = false;
		if (smsReply != null) {
			if (smsReply.isSundayEnable() == false
					&& smsReply.isMondayEnable() == false
					&& smsReply.isTuesdayEnable() == false
					&& smsReply.isWednesdayEnable() == false
					&& smsReply.isThursdayEnable() == false
					&& smsReply.isFridayEnable() == false
					&& smsReply.isSaturdayEnable() == false) {
				result = true;
			}
		}

		return result;
	}

	public static boolean isNeverRepeat(Cursor cursor) {
		boolean result = false;
		if (cursor != null) {
			if (cursor
					.getInt(cursor
							.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_SUNDAY_ENABLE)) == 0
					&& cursor
							.getInt(cursor
									.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_MONDAY_ENABLE)) == 0
					&& cursor
							.getInt(cursor
									.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_TUESDAY_ENABLE)) == 0
					&& cursor
							.getInt(cursor
									.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_WEDNESDAY_ENABLE)) == 0
					&& cursor
							.getInt(cursor
									.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_THURSDAY_ENABLE)) == 0
					&& cursor
							.getInt(cursor
									.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_FRIDAY_ENABLE)) == 0
					&& cursor
							.getInt(cursor
									.getColumnIndexOrThrow(SmsReplyContract.SmsReplies.IS_SATURDAY_ENABLE)) == 0) {
				result = true;
			}
		}

		return result;
	}

	public static boolean isAlwaysRepeat(SmsReply smsReply) {
		boolean result = false;
		if (smsReply != null) {
			if (smsReply.isSundayEnable() == true
					&& smsReply.isMondayEnable() == true
					&& smsReply.isTuesdayEnable() == true
					&& smsReply.isWednesdayEnable() == true
					&& smsReply.isThursdayEnable() == true
					&& smsReply.isFridayEnable() == true
					&& smsReply.isSaturdayEnable() == true) {
				result = true;
			}
		}

		return result;
	}
}
